<template>
  <div>
    <div class="news-wrapper">
      <div>
        <ul class="top-list">
          <li
            v-for="(item, index) in listName"
            :key="index"
            @click="getNewsInfo(item.classtify)"
            :class="{'cur': isColor}"
          >
            {{item.classtifyName}}
          </li>
        </ul>
      </div>
      <div class="content">
        <p v-for="(item, index) in newsInfo" :key="index">
          <span>{{item.newsTitle}}</span>
          <i>{{item.newsDate}}</i>
        </p>
        <!-- <div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="30">加载中.....</div> -->
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data () {
    return {
      newsInfo: [],
      isColor: false,
      busy: true,
      page: 1,
      pageSize: 3,
      listName: [
        {
          classtifyName: '行业资讯',
          classtify: 'H'
        },
        {
          classtifyName: '公司新闻',
          classtify: 'G'
        },
        {
          classtifyName: '专题新闻',
          classtify: 'Z'
        }
      ]
    }
  },
  methods: {
    getNewsInfo (classtify) {
      var param = {
        classtify: classtify
      }
      axios.get('/news/newsList', {
        params: param
      }).then((res) => {
        if (res.data.status === 0) {
          this.newsInfo = res.data.result.list
        } else {
          this.newsInfo = []
        }
      })
    },
    loadMore () {
      this.busy = true
      setTimeout(() => {
        this.page++
        this.getNewsInfo(true)
      }, 1000)
    }
  }
}
</script>

<style lang="scss" scoped>
.news-wrapper {
  width: 70%;
  // background-color: pink;
  margin: 20px auto;
  margin-bottom: 30px;
  .top-list {
    width: 40%;
    margin: 40px auto;
    display: flex;
    li {
      padding: 10px 35px 10px 30px;
      background-color: #bf803e;
      flex-direction: row;
      justify-content: space-between;
      text-align: center;
      color: #fff;
    }
    li:hover {
      background-color: #ac6e2e;
      font-weight: 700;
    }
    .cur {
      background-color: #ac6e2e;
      font-weight: 700;
    }
  }
  .content {
    p {
      width: 100%;
      height: 20px;
      // background-color: red;
      border-bottom: 1px dashed #bf803e;
      margin-bottom: 20px;
      span {
        color: #8f6228;
      }
      i {
        float: right;
        color: #8f6228;
      }
    }
  }
}
</style>
